package com.example.test_20230602;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.DateFormat;
import java.util.Date;

@WebServlet("/servletResponse")
public class ServletResponse extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html;charset=utf8");
        resp.setStatus(200);
        resp.setHeader("Refresh", "3");
        resp.getWriter().write("timeStamp:" + System.currentTimeMillis());

        DateFormat df1 = null;
        DateFormat df2 = null;
        df1 = DateFormat.getDateInstance();
        df2 = DateFormat.getDateTimeInstance();
//        System.out.println("DATE:" + df1.format(new Date()));
//        System.out.println("DATETIME:" + df2.format(new Date()));

        resp.getWriter().write("<br>");
        resp.getWriter().write("DATE:" + df1.format(new Date()));
        resp.getWriter().write("<br>");
        resp.getWriter().write("DATE:" + df2.format(new Date()));
    }
}
